{extend name="main/index" /}
{block name="main"}
<div class="main-content">
    <div class="breadcrumbs" id="breadcrumbs">
        <script type="text/javascript">
            try{ace.settings.check('breadcrumbs' , 'fixed')}catch(e){}
        </script>

        <ul class="breadcrumb">
            <li>
                <i class="icon-home home-icon"></i>
                <a href="#">经营管理模块</a>
            </li>
            <li class="active">投标信息总览</li>
        </ul><!-- .breadcrumb -->
        <div class="nav-search" id="nav-search">
            <form class="form-search">
                <span class="input-icon">
                    <input type="text" placeholder="Search ..." class="nav-search-input" id="nav-search-input" autocomplete="off" />
                    <i class="icon-search nav-search-icon"></i>
                </span>
            </form>
        </div><!-- #nav-search -->
    </div>

    <div class="page-content">
        <h3 class="header smaller lighter blue">投标信息总览</h3>
        <div class="row">
            <div class="col-xs-12">
                <div class="row">
                    <div class="col-xs-12">
                        <div class="table-responsive">
                            <table id="sample-table-2" class="table table-striped table-bordered table-hover">
                                <thead>
                                    <tr>
                                        <th>ID</th>
                                        <th>招标单位</th>
                                        <th class="hidd240">投标项目</th>
                                        <th class="hidden-240">招标时间</th>
                                        <th class="hidden-240">招标地点</th>
                                        <th class="hidden-240">是否中标</th>
                                        <th class="hidden-240">流程状态</th>
                                        <th class="hidden-240">操作</th>
                                    </tr>
                                </thead>
                                <tbody>
                                {volist name="list" id="v"}
                                    <tr>
                                        <td>{$v['id']}</td>
                                        <td>{$v['tenderer']}</td>
                                        <td>{$v['bid_project']}</td>
                                        <td>{$v['bids_time']}</td>
                                        <td>{$v['bids_address']}</td>
                                        <td>
                                            {$v['success']==1?'是':'否'}
                                        </td>
                                        <td>
                                            {switch name=$v['status']}
                                                {case value="1" break="1"}流程未发起{/case}
                                                {case value="9" break="1"}流程已完结{/case}
                                                {default /}流程审核中
                                            {/switch}
                                         </td>
                                        <td>
                                            <button  data-id="{$v['id']}" class="btn btn-xs btn-primary show-btn" data-toggle="modal"
                                data-target="#myModal" >查看详情</button>
                                            <button data-id="{$v['id']}" class="btn btn-xs btn-danger del-btn" >撤销</button>
                                            <!-- <a href="{:url('admin/bids/details', ['id' => $v['id']])}">查看详情</a> |  -->
                                             <!-- <a href="">撤销</a> -->
                                         </td>
                                    </tr>
                                {/volist}
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div><!-- /.col -->
        </div><!-- /.row -->
    </div><!-- /.page-content -->
</div>

<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <div class="col-xs-12">
                    <div class="form-group">
                        <div class="col-sm-9">
                            <label class="col-sm-3 control-label no-padding-right" for="form-field-1">   </label>
                            <div class=" "></div>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-sm-9">
                            <label class="col-sm-3 control-label no-padding-right" for="form-field-1"> 项目名称 : </label>
                            <div class="bid_project"></div>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-sm-9">
                            <label class="col-sm-3 control-label no-padding-right" for="form-field-2"> 招标单位 : </label>
                            <div class="tenderer"></div>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-sm-9">
                            <label class="col-sm-3 control-label no-padding-right" for="form-field-2"> 招标时间 : </label>
                            <div class="bids_time"></div>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-sm-9">
                            <label class="col-sm-3 control-label no-padding-right" for="form-field-2"> 招标地点 : </label>
                            <div class="bids_address"></div>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-sm-9 ">
                            <label class="col-sm-3 control-label no-padding-right" for="form-field-2"> 需求分析 : </label>
                            <div class="demand_analysis"></div>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-sm-9">
                            <label class="col-sm-3 control-label no-padding-right" for="form-field-2"> 项目建议书 : </label>
                            <div class="project_proposal"></div>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-sm-9">
                            <label class="col-sm-3 control-label no-padding-right" for="form-field-2"> 是否中标 : </label>
                            <div class="success"></div>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-sm-9">
                            <label class="col-sm-3 control-label no-padding-right" for="form-field-2"> 流程状态 : </label>
                            <div class="status"></div>
                        </div>
                    </div>
                </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary" data-dismiss="modal">Close</button>
            </div>
        </div>
    </div>
</div>


{/block}

{block name="myjs"}
{js href="/static/admin/assets/js/toastr.min.js"}
<script>
    $(function(){
        $('.show-btn').click(function () {
            var ac_id = $(this).attr('data-id');
            console.log('我要查询: ' + ac_id + '的项目施工内容');
            showAjax(ac_id);
        });

        $('.del-btn').click(function () {
            var ac_id = $(this).attr('data-id');
            console.log('我要删除: ' + ac_id + '的项目');
            if (confirm('你确定要 [ 撤 销 ] 吗?')) {
                var obj = $(this).parents('tr');
                // console.log(obj);
                delAjax(ac_id, obj);
            }
        });
    });

    function showAjax(id) {
        $.ajax({
            type: 'get',
            url: '/bids/' + id,
            dataType: 'json',
            success: function (data) {
                // console.log(data);
                    //  modal填充
                    $('.bid_project').html(data.bid_project);
                    $('.tenderer').html(data.tenderer);
                    $('.bids_time').html(data.bids_time);
                    $('.bids_address').html(data.bids_address);
                    $('.demand_analysis').html(data.demand_analysis);
                    $('.project_proposal').html(data.project_proposal);
                    $('.success').html(data.success);
                    $('.status').html(data.status);
            },
            error: function () {
                alert('AJAX执行失败');
            }
        });
    }
    // 执行ajax删除
    function delAjax(id, obj) {
        $.ajax({
            type: 'delete',
            url: '/bids/' + id,
            dataType: 'json',
            success: function (data) {
                console.log(data);
                if (data.status) {
                    toastr.success(data.info);
                    obj.remove();
                } else {
                    toastr.error(data.info, 'FBI WARNING:');
                }
            },
            error: function () {
                alert('AJAX执行失败');
            }
        });
    }
</script>

{/block}